package com.itheima.config;

import com.itheima.interceptor.DemoInterceptor;
import com.itheima.interceptor.LoginCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
   @Autowired
    private DemoInterceptor demoInterceptor;

   @Autowired
    private LoginCheckInterceptor loginCheckInterceptor;
    //注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(demoInterceptor)
//                // '/**'代表任意路径 '/*'代表一级路径
//                .addPathPatterns("/**") //拦截所有请求
//             .excludePathPatterns("/emp/login"); //放行登录请求
//     registry.addInterceptor(loginCheckInterceptor)
//             .addPathPatterns("/**")
           ; //放行登录请求
    }
}
